package com.bifrost.service;

import com.bifrost.entity.*;
import com.bifrost.exception.InventoryUnavailableException;
import com.bifrost.model.promotion.PromotionModel;
import com.bifrost.model.promotion.SeckillModel;
import com.bifrost.model.promotion.SeckillTimeModel;
import com.bifrost.model.ro.OrderPointRO;

import java.util.Date;
import java.util.List;

/**
 * @author rangf
 * @date 2018/3/5
 */
public interface PromotionService {

    /**
     * 获取促销列表
     *
     * @param type 促销类型
     * @param store store
     * @return
     */
    public List<PromotionModel> list(MerchantStore store, String type);

    /**
     * 获取促销明细
     *
     * @param promotionSkuId promotionSkuId
     * @return
     */
    public PromotionModel promotion(Long promotionSkuId);

    /**
     * 获取当天秒杀List
     *
     * @param storeId
     * @return
     */
    public List<SeckillTimeModel> seckillTimes(Long storeId);

    /**
     * 根据秒杀开始秒杀时间获取秒杀model
     *
     * @param store
     * @param startTime
     * @return
     */
    public SeckillModel seckillList(MerchantStore store, Date startTime);

    /**
     * 查找指定的促销
     * @param promotionId
     * @return
     */
    Promotion find(Long promotionId);

    /**
     * 促销活动是否还有效
     * @param promotion
     * @return
     */
    boolean isActive(Promotion promotion);

    /**
     * 查询指定sku某促销的信息
     * @param promotion
     * @param sku
     * @return
     */
    PromotionSku findByPromotionAndSku(Promotion promotion, ProductSku sku);

    boolean isAvailable(Promotion promotion, ProductSku sku);
    boolean isAvailable(Long promotionId, Long  skuId);

    PromotionSku findById(Long promotionSkuId);

    PromotionSku save(PromotionSku promotionSku);

    /**
     * decrementInventory
     *
     * @param promotionSku
     * @param quantity
     * @return
     */
    public int decrementInventory(PromotionSku promotionSku, Integer quantity);

    /**
     * incrementInventory
     *
     * @param promotionSku
     * @param quantity
     * @return
     */
    public int incrementInventory(PromotionSku promotionSku, Integer quantity);

    /**
     * 参数校验:积分兑换
     *
     * @param ro ro
     * @return
     */
    public String validateExchangeParam(OrderPointRO ro);

    /**
     * 积分兑换校验
     *
     * @param customer customer
     * @param promotionSku promotionSku
     * @param ro ro
     * @return
     */
    public String validateExchange(Customer customer, PromotionSku promotionSku, OrderPointRO ro);

    /**
     * 积分兑换
     *
     * @param customer customer
     * @param ro ro
     */
    public Order exchange(Customer customer, PromotionSku promotionSku, OrderPointRO ro) throws InventoryUnavailableException;

}
